import {ref} from 'vue'
import http from '@/utils/request'

// 定义所有需要的变量
const msg = ref('Hello World')
const count = ref(0)
const isLoading = ref(false)
const testResponse = ref('')

// 定义fetchTest函数
const fetchTest = () => {
  isLoading.value = true
  http.get('/test', {params: {wd: 'vue3'}})
    .then(data => {
      testResponse.value = `请求成功: ${data} `
    })
    .catch(error => {
      testResponse.value = `请求失败: ${error.message}`
    })
    .finally(() => {
      setTimeout(() => {
        isLoading.value = false
      }, 1000)
    })
}

// 导出所有需要在模板中使用的变量和函数
export {msg, count, isLoading, testResponse, fetchTest}